/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gen.seam.util.file;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 *
 * @author Gustavo
 */
public class FileProcessor {

    public static File write(String fileName, String path, String... lines) throws IOException {
        if (path.charAt(path.length() - 1) != '/') {
            path = path.concat(File.separator);
        }
        try {
            BufferedWriter bufWriter = new BufferedWriter(new FileWriter(path + fileName));
            String texto;
            for (int i = 0; i < lines.length; i++) {
                texto = String.valueOf(lines[i]);
                bufWriter.write(texto);
                bufWriter.newLine();
            }
            bufWriter.flush();
            bufWriter.close();

        } catch (IOException e) {
            throw new IOException("Something appears wrong during the generate process. Please, mail this message", e);
        }

        return new File(path + fileName);
    }
}
